@extends('admin.master')

@section('style')
    <link rel="stylesheet" href="{{ url('js/prettyphoto/css/prettyPhoto.css') }}">
@endsection

@section('top')
	<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
	<div class="top-btn-group pull-right">
		<a href="{{ route('admin.contract.create', ['cid'=>$cid]) }}" class="btn btn-primary">添加合同 / 发票</a>
	</div>
@endsection

@section('content')
{!! Form::open(['url'=>'admin/contract']) !!}
	<table class="table table-hover">
		<thead>
			<tr>
				<th width="60">ID</th>
				<th>客户名称</th>
				<th>添加时间</th>
				<th>合同号</th>
                <th>合同图片</th>
                <th>发票回执</th>
				<th>发票状态</th>
				<th>发票回执</th>
				<th>发票类型</th>
				<th>备注</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
			@if (!$contracts->isEmpty())
				@foreach ($contracts as $value)
				<tr>
					<td>{{ $value->id }}</td>
					<td>{{ $customer->name }}</td>
					<td>{{ $value->created_at->format('Y-m-d') }}</td>
					<td><code>{{ $value->contract_no }}</code></td>
					<td>
					@if ($value->contract)
						<ul class="contract-imgs">
							@foreach($value->contract as $contract)
		                    <li>
		                        <a href="{{ url($contract) }}" class="thumbnail" rel="prettyPhoto[contracts-{{ $i }}]">
		                        	<img src="{{ thumbFull($contract, 80) }}">
		                        </a>
		                    </li>
							@endforeach
						</ul>
					@endif
					</td>
					<td>
					@if ($value->invoice_receipt)
						<ul class="contract-imgs">
							@foreach($value->invoice_receipt as $receipt)
		                    <li>
		                        <a href="{{ url($receipt) }}" class="thumbnail" rel="prettyPhoto[receipts-{{ $i }}]">
		                        	<img src="{{ thumbFull($receipt, 80) }}">
		                        </a>
		                    </li>
							@endforeach
						</ul>
					@endif
					</td>
					<td>
						@if ($value->invoice_status)
							<span class="text-success">发票已开</span>
						@endif
					</td>
					<td>
						@if ($value->invoice_receipt_status)
							<span class="text-success">发票回执已收</span>
						@endif
					</td>
					<td>{{ config('system.invoice_type')[$value->invoice_type] }}</td>
					<td>{{ $value->remark }}</td>
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.contract.edit', $value->id) }}" class="btn-link">修改</a>
							<span class="text-explode ">|</span>
							<a href="javascript:void(0);" data-id="{{ $value->id }}" class="btn-link delete-item">删除</a>
						</div>
					</td>
				</tr>
				@endforeach
			@endif
		</tbody>
	</table>
{!! Form::close() !!}
@endsection

@section('foot')
<script src="{{ url('js/prettyphoto/jquery.prettyPhoto.js') }}"></script>
<script>
$(function() {
	$("a[rel^='prettyPhoto']").prettyPhoto({social_tools: ''});
});
</script>
@endsection